#include <exception>
#include "Device.h"
#include "SwitchOffCommand.h"

SwitchOffCommand::SwitchOffCommand(Device * dev) {
	if (dev == 0) { throw std::exception("null pointer in SwitchOffCommand()..."); }
	mDevice = dev;
	mLastState = dev->getOnOffState();
}

void SwitchOffCommand::Execute() {
	mLastState = mDevice->getOnOffState();
	mDevice->SwitchOff();
}

void SwitchOffCommand::Undo() {
	mDevice->setOnOffState(mLastState);
}